<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/vue.js"></script>
    <script src="../js/vue-router.js"></script>
</head>
<body>
    <div id="app">
        <ul>
            <!--<router-link> 默认会被渲染成一个 <a>`标签-->
            <li><router-link to="/login">登录</router-link></li>
            <li><router-link to="/register">注册</router-link></li>
        </ul>
        <!--路由中定义的组件会替换router-view标签-->
        <router-view></router-view>
    </div>
</body>
<script>
    //获取路由对象
    var re = new VueRouter({
        //定义路由规则
        routes:[
            //{请求的路径，component是模板}
            {path:"/login",component:{template:"<h1>login</h1>"}},
            {path:"/register",component:{template:"<h1>register</h1>"}}
        ]
    });

    var app = new Vue({
        el:"#app",
        //将router对象传给vue实例
        router:re
    });
</script>
</html>

